import os
import sys

import numpy as np
from PIL import Image, ImageDraw, ImageFont

sys.path.append(os.pardir)


def pic_text(image, xy, text, font=None, fill=None, direction=None):
    # 新建绘图对象

    draw = ImageDraw.Draw(image)
    font = ImageFont.truetype('C:\Windows\Fonts\Calibri.ttf', size=50)
    draw.text(xy, text, font=font, fill=fill, direction=direction)


def img_zoom(img, zoom=1):
    size = img.size[0] * zoom, img.size[1] * zoom
    return img.resize(size, Image.ANTIALIAS)


# 显示识别有误的图片
def convert_img(img):
    return Image.fromarray(np.uint8(img))
